#include <stdio.h>
#include <ctype.h>
void reverse_name(char *name);
int main(void)
{
    printf("Enter a first and last name: ");
    char name[50];
    fgets(name, 50, stdin);
    reverse_name(name);
    puts(name);
    return 0;
}
void reverse_name(char *name) {
    char *p = name, fname;
    while (isspace(*p))  /* fname 之前的空格 */
        p++;
    fname = toupper(*p);
    while (!isspace(*p))  /* 找到 fname 结束 */
        p++;
    while (isspace(*p))  /* 跳过 fname 和 lname 之间的空格 */
        p++;
    char *q = name;
    while (!isspace(*p))
        *q++ = *p++;
    *q++ = ',';
    *q++ = ' ';
    *q++ = fname;
    *q++ = '.';
    *q++ = '\0';
}